package com.canbot.u05.activity.admin;

import android.util.Base64;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;

/**
 * desc: 生成Token的工具类
 * author: xxl
 * date: 2019/6/19
 */
public class TokenProccessor {
     
     private TokenProccessor(){}
     private static final TokenProccessor instance = new TokenProccessor();
      
    public static TokenProccessor getInstance() {
        return instance;
    }
  
    /**
     * 生成Token
     * @return
     */
    public String makeToken() {
        String token = (System.currentTimeMillis() + new Random().nextInt(999999999)) + "";
         try {
            MessageDigest md = MessageDigest.getInstance("md5");
             byte[] md5 = md.digest(token.getBytes());
            return Base64.encodeToString(md5, Base64.DEFAULT);
        } catch (NoSuchAlgorithmException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
         return null;
    }
}